//获取元素
var input1 = $(".input1");
var input2 = $(".input2");
var checkbox = $(".checkbox");
var button = $(".button");
var box2 = $(".box2");
var myDate = new Date();
var timer = "";
var h = myDate.getHours(); //获取当前小时数(0-23)
var m = myDate.getMinutes(); //获取当前分钟数(0-59)
var s = myDate.getSeconds(); //获取当前秒
var str = h + ":" + m + ":" + s;

button.click(() => {
  var name = input1.val();
  var content = input2.val();
  console.log(name);
  //判断早/中/晚
  if (h < 12) {
    timer = "上午";
  } else if (h < 18) {
    timer = "上午";
  } else {
    timer = "晚上";
  }
  //判断内容是否为空
  if (name === "" || content === "") {
    alert("昵称和内容不能为空");
  }
  //判断复选框是否被选上
  if (checkbox.is(":checked")) {
    console.log("被选中");
    name="路人甲"
  } else {
    console.log("没被选中");
  }
  var newlist = $(
    '<div class="contentbox">'+"昵称："+name
    +"<span>"+timer+str+"</span>"+
    '<div class="content">'+content+"</div>"+
    '</div>'
  );

  box2.append(newlist);
});
